<template>
	<view>
	
		<uni-nav-bar statusBar="true"
		:fixed="true" :border="false" 
		bgcolor="#1D7DFF"
		color="#ffffff"
		backgroundColor="#1D7DFF">
			<view class="index-top-nav-title" slot="middle">
				<view class="leftIcon" @tap.stop="back">
					<i class="icon iconfont icon-arrow-left"></i>
				</view>
				<view class="index-top-nav-title-content">
					{{i18n.CurrentInvestment}}
							<!-- {{curObj.title}} -->
				</view>
				<view class="index-top-nav-r" @tap.stop="jumpList">
					<view class="index-top-nav-title-t">{{i18n.bili}}</view>
				</view>
			</view> 
		</uni-nav-bar>
		<view class="fund-live-title">
			<view class="fund-live-title-top">
				{{i18n.Net_asset_valuation}} Block
				<!-- <view> -->
				<!-- <text class="iconfont icon-arrow-down"></text> -->
				<!-- </view> -->
			</view>
			<view class="fund-live-title-center">
				{{jing_total}}
			</view>
			
			<view class="fund-live-title-bottom">
				<view class="fund-live-title-bottom-item">
					<text>{{i18n.yesterday_income}}(Block)</text>
					<view>{{daysum}}</view>
				</view>
				<view class="fund-live-title-bottom-item">
					<text>{{i18n.total_income}}(Block)</text>
					<view>{{totalsum}}</view>
				</view>
			</view>
		</view>
		
		
		<view class="fund-live-tip">
			<view class="fund-live-tip-item">
				<swiper circular="true" vertical="true" :autoplay="true" :interval="3000" :duration="1000">
					<swiper-item v-for="(item, index) in news" :key="index" @tap="clickBullentin(item)">
						<view class="swiper-item overTxt bulletin-txt">{{item.phone}} {{item.num}} {{item.token}}</view>
					</swiper-item>
				</swiper>
			</view>
			<view class="fund-live-tip-item-b">
				<view>{{i18n.Cumulative_participation_in_current_treasure}}</view>
				<view>{{totals}}人次</view>
			</view>
		</view>
		
		
		<view class="fund-live-cur">
			<view class="fund-live-cur-nav">
				<text>{{i18n.Currency}}</text>
				<text>{{i18n.Daily_profit_rate}}</text>
				<text>{{i18n.Saved}}</text>
			</view>
			
				
			<block v-for="(item,index) in liveCurlist" :key="index">
				<view class="fund-live-cur-item"  @tap.stop="jumpFundLiveList(item)">
					
					<view class="fund-live-cur-item-i">
						<!-- <image :src="item.logo" mode="widthFix" lazy-load></image> -->
						<text>{{item.coin}}</text>
					</view>
					
					<view class="fund-live-cur-item-l">{{item.sl}}</view>
					<view class="fund-live-cur-item-t">
						<view class="">{{item.buy_num}}</view>
						<text class="">{{i18n.maximum}} {{item.max}} $</text>
					</view>
				</view>
			</block>
		</view>
		
		
		
		<load v-if="showLoad"></load>
	</view>
</template>

<script>
	import Toast from '@/components/toast/toast.vue';
	import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue';
	import Load from '../../components/common/load.vue';
	import {fetch, _updataTabBar, showToast, pageto, forceUpdate} from '@/common/js/util.js';
	import {mapGetters, mapMutations} from 'vuex' 
	export default {
		data() {
			return {
				showLoad:false,
				// list:[],
				totals:'',
				news:[],
				liveCurlist:[],
				daysum:0,
				totalsum:0,
				jing_total:0
			}
		},
		onShow() {
			this.getsList();
			this.empty();
			this.getSHopList();
			this.getLList();
			this.getWallet();
		},
		onNavigationBarButtonTap(e) {
			console.log(e);
			if(e.index==0){
				this.jumpList()
			}
		},
		computed:{
			i18n() {
				return this.$t('message');
			},
			...mapGetters([
				'getRequestUrl',
				"getLoginInfo",
				'getTextArr',
				'getLangType',
				'getLang'
			])
		},
		components:{
			Toast,uniNavBar,Load
		},
		methods:{
			...mapMutations(['setPackages']),
			getsList(){
				let url = this.getRequestUrl + '/api/User/detailed';
				let _data = {
					id : this.getLoginInfo.id,
					token : this.getLoginInfo.token
				}
				fetch(url,_data,"POST").then(res=>{
					if(res.data.code){
						console.log(JSON.stringify(res));
						this.daysum = res.data.data.day_sum+''
						// console.log(this.daysum);
						this.totalsum = res.data.data.sum+''
					}
				})
			},
			getSHopList(){
				let url = this.getRequestUrl + '/api/Shop/shop_list';
				let _data = {
					id : this.getLoginInfo.id,
					token : this.getLoginInfo.token,
					type: 2
				}
				fetch(url,_data,"POST").then(res=>{
					// this.getSHopList2();
					if(res.data.code){
						// this.liveCurlist = res.data.data;
						this.liveCurlist = res.data.data;
						
					}
				})
			},
			getLList(){
				let url = this.getRequestUrl + '/api/Shop/buy_list';
				// this.showLoad = true;
				fetch(url,'',"POST").then(res=>{
					if(res.data.code){
						this.showLoad = false;
						this.totals = res.data.data[res.data.data.length-1]
						// console.log(this.totals);
						 res.data.data.splice(res.data.data.length-1,1)
						 this.news = res.data.data 
						// console.log(this.news);
					}
				}).catch(err=>{this.showLoad = false;})
			},
			getWallet(){
				let url = this.getRequestUrl + "/api/wallet/wallet_list";
				let _data = {
					id : this.getLoginInfo.id,
					token : this.getLoginInfo.token
				}
				this.showLoad = true;
				fetch(url,_data,"POST").then(res=>{
					if(res.data.code){
						this.showLoad = false;
						// this.jing_total = res.data.data
						// this.list = res.data.data.list;
						let datas = res.data.data.list.filter((item,index)=>{
							return item.title_en == 'Block';
						})
						this.jing_total = datas[0].balance
						console.log(datas)
					}
				}).catch(err=>{this.showLoad = false;})
			},
			jumpFundLiveList(item){
				let list = JSON.stringify(item)
				this.setPackages(list)
				uni.navigateTo({
					url:'/pages/fund/fund-live-list'
				})
			},
			back(){
				uni.navigateBack({
					delta:1
				})
			},
			jumpList(){
				console.log('11');
				uni.navigateTo({
					url:'/pages/fund/list'
				})
			},
			empty(){
				this.showLoad = false;
				this.isClick = false;
			}
		}
	}
	
</script>

<style lang="scss" scoped>
	.index-top-nav-title{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 30upx;
		view{
			font-size:36upx;
			font-weight: bold;
		}
		text{
			font-size:26upx;
			font-weight: 100;
		}
	}
	.fund-live-title{
		background-color: #1D7DFF;
		color: #FFFFFF;
		padding: 10upx 0 4upx 0;
		position: relative;
		.fund-live-title-top{
			text-align: center;
			font-size: 24upx;
			display: flex;
			justify-content: center;
			align-items: center;
			view{
				display: flex;
				margin-left: 12upx;
				justify-content: space-between;
				align-items: center;
				border: 2upx solid #FFFFFF;
				padding: 8upx 30upx 8upx 8upx;
				font-size: 24upx;
				width: 120upx;
				text{
					font-size: 26upx;
					font-weight: 100;
					color: #FFFFFF;
				}
			}
		}
		.fund-live-title-center{
			font-size: 40upx;
			font-weight: bold;
			text-align: center;
			padding:46upx 0 66upx 0;
		}
		.fund-live-title-bottom{
			background-color: #FFFFFF;
			border-radius: 10upx;
			position: absolute;
			width: 690upx;
			left: 50%;
			transform: translate(-50%,50%);
			bottom: 0;
			display: flex;
			align-items: center;
			margin-bottom: -20upx;
			padding: 20upx 0;
			box-shadow: 2upx 2upx 10upx #e3e3e3;
			.fund-live-title-bottom-item{
				&:first-of-type{
					position: relative;
					&::after{
						position: absolute;
						right: 0;
						top: 0;
						height: 100%;
						width: 2upx;
						content:"";
						background-color: #a4a4a4;
					}
				}
				color: #282828;
				flex: 1;
				text-align: center;
				text{
					font-size: 24upx;
				}
				view{
					padding: 0 20upx;
					font-size: 36upx; 
					font-weight: bold;
				}
			}
		}
	}
	.fund-live-tip{
		border-top: 120upx solid #f0f0f0;
		border-bottom: 26upx solid #f0f0f0;
		padding: 26upx 30upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.fund-live-tip-item{
			flex: 1;
			swiper {
				height: 58upx;
				flex: 1;
				.swiper-item {
					font-size: 25upx;
					line-height: 54upx;
					width: 450upx;
					overflow: hidden;
					text-overflow:ellipsis;
					color: #282828;
					white-space: nowrap;
				}
			}
		}
		.fund-live-tip-item-b{
			width: 180upx;
			font-size: 24upx;
			color: #166AFE;
			text-align: right;
		}
	}
	.fund-live-cur{
		.fund-live-cur-nav{
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding:38upx 30upx 0;
			text{
				font-size: 24upx;
				color: #282828;
			}
		}
		.fund-live-cur-item{
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 40upx 37upx 30upx 43upx;
			border-bottom: 1upx solid #D1D1D1;
			.fund-live-cur-item-i{
				display: flex;
				align-items: center;
				image{
					width: 75upx;
					height: 75upx;
					// margin-right: 26upx;
				}
				text{
					font-size:32upx;
					font-weight: bold;
				}
			}
			.fund-live-cur-item-l{
				color: #166AFE;
				font-size: 34upx;
				font-weight: bold;
			}
			.fund-live-cur-item-t{
				text-align: right;
				view{
					font-size:30upx;
					color: #2a2a2a;
				}
				text{
					font-size: 24upx;
					color: #929292;
				}
			}
		}
	}
</style>